<?php
/**
 * @author li ming
 * @date 2021-10-12
 */
namespace Modules\User\Validate\Api;

use Modules\User\Validate\BaseValidate;

class AddressValidate extends BaseValidate
{

    protected $rule = [
        'name' => 'required|string|min:1|max:30',
        'phone' => 'required',
        'province_id' => 'required|integer',
        'province' => 'required|string',
        'city_id' => 'required|integer',
        'city' => 'required|string',
        'region_id' => 'required|integer',
        'region' => 'required|string',
        "detail" => "required|string",
        "address_id" => "required|integer"
    ];

    protected $message = [
        'name.required' => '收货人姓名不能为空',
        'name.string' => '收货人姓名格式不对',
        'name.min' => '收货人姓名格式不对',
        'name.max' => '收货人姓名格式不对',
        'phone.required' => '联系电话不能为空',
        'province_id.required' => '请选择省份',
        'province_id.integer' => '请选择省份',
        'province.required' => '省份不能为空',
        'province.string' => '省份格式不对',
        'city_id.required' => '请选择城市',
        'city_id.integer' => '请选择城市',
        'city.required' => '城市不能为空',
        'city.string' => '城市格式不对',
        'region_id.required' => '请选择区/县',
        'region_id.integer' => '请选择区/县',
        'region.required' => '区/县不能为空',
        'region.string' => '区/县格式不对',
        'detail.required' => '详细地址不能未空',
        'detail.string' => '详细地址格式不对',
        "address_id.required" => '地址ID不能为空',
        "address_id.integer" => '地址ID格式不对',
    ];

    protected $scene = [
        'add' => ['name', 'phone', 'province_id', 'city_id', 'region_id', 'detail'],
        'empower_add' => ['name', 'phone', 'province', 'city', 'region', 'detail'],
        'edit' => ['name', 'phone', 'province_id', 'city_id', 'region_id', 'detail', 'address_id'],
        'save_default' => ['address_id'],
        'del' => ['address_id'],
    ];
}